//
//  tabBarController.m
//  UITabBarController
//
//  Created by 王恕 on 15/12/31.
//  Copyright © 2015年 王恕. All rights reserved.
//

#import "tabBarController.h"
#import "firstViewController.h"
#import "secondViewController.h"
#import "thirdViewController.h"

@interface tabBarController ()<UITabBarControllerDelegate>

@property (nonatomic, strong) UITabBarController *myTabBarController;


@end

@implementation tabBarController
@synthesize myTabBarController;

- (id)init{
    if (self = [super init]) {
     
        [self myTabBarController];
    }
    return self;
}

- (UITabBarController *)myTabBarController{

    if (!myTabBarController) {

        
        //创建UIViewController对象
        firstViewController *firstController = [[firstViewController alloc] init];
        secondViewController *secondController = [[secondViewController alloc] init];
        thirdViewController *thirdController = [[thirdViewController alloc] init];
        thirdViewController *forthController = [[thirdViewController alloc] init];
        thirdViewController *fifteenController = [[thirdViewController alloc] init];
        thirdViewController *sixteenController = [[thirdViewController alloc] init];
        //设置UIViewController的viewController属性
        
        self.viewControllers = @[firstController,secondController,thirdController,forthController,fifteenController,sixteenController];//有几个添加几个
        self.selectedViewController = thirdController;//设置当前选中的controller
        self.selectedIndex = 1;//通过设置index来获取当前的controller
        self.customizableViewControllers = @[fifteenController,secondController];
        self.delegate = self;
        
        }
   
    
        return myTabBarController;
}

//是否允许切换

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    return YES;

}
//当选中某一个item时候调用
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    NSLog(@"didSelect");
}


//当more中edit按钮点击时候调用
- (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers {
    NSLog(@"willBeginCustomizing");

}
//当more中edit要退出时调用
- (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers changed:(BOOL)changed {

     NSLog(@"willEndCustomizing");
}

//当more中edit要退出调用
- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers changed:(BOOL)changed{
     NSLog(@"didEndCustomizing");

}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
